package ca.compsci.opent.doctool;

/**
 * Models a constant in OpenT
 * 
 * @since 0.0.2
 */
public class Const extends Var
{
	/**
	 * Value of this constant.
	 * 
	 * @since 0.0.2
	 */
	private String value;
	
    /**
     * Creates a new {@code Const}.
     *
     * @param identifier the constant identifier in code
	 * @param type type that this constant is in OpenT code
	 * @param value value of this constant
	 * 
	 * @since 0.0.2
     */
    public Const(String identifier, Type type, String value)
    {
        super(identifier, type);
		this.value = value;
    }
	
	/**
	 * Returns the value of this constant, as a string.
	 * 
	 * @return value of constant
	 * 
	 * @since 0.0.2
	 */
	public String getValue()
	{
		return value;
	}
	
	/**
	 * Returns a string representation.
	 * 
	 * <p>
	 * The representation is {@code const <i>identifier</i> : 
	 * <i>type</i> := <i>value</i>}.
	 * </p>
	 * 
	 * @return string representation of this {@code Const}
	 * 
	 * @since 0.0.2
	 */
	@Override
	public String toString()
	{
		return super.toString().replace("var", "const") + " := " + value;
	}

}
